package communication;

import java.util.HashMap;
import java.util.Vector;

import com.aol.acc.AccPreferencesHook;

public class AIMPrefsHook extends AccPreferencesHook {
	// OVERVIEW: The preferences object is used for getting and setting
	// preference values. This code has been provided by AOL.
	HashMap<String, String> map = new HashMap<String, String>();

	@Override
	public String[] getChildSpecifiers(final String specifier) {
		final Vector<String> v = new Vector<String>();
		for (final String s : this.map.keySet()) {
			if (s.startsWith(specifier) && !s.equals(specifier)) {
				v.add(s);
			}
		}

		if (v.size() > 0) {
			return v.toArray(new String[0]);
		} else {
			return null;
		}
	}

	@Override
	public String getDefaultValue(final String specifier) {
		return null;
	}

	@Override
	public String getValue(final String specifier) {
		return (this.map.get(specifier));
	}

	@Override
	public void reset(final String specifier) {
		this.map.put(specifier, null);
	}

	@Override
	public void setValue(final String specifier, final String value) {
		this.map.put(specifier, value);
	}
}